package org.donghuan.rms.framework.domain;

import java.util.ArrayList;
import java.util.List;

public abstract class EntityListenerAdapter implements IEntityListener {
	private static List<IPropertyChangedListener> listeners;

	@Override
	public void addEntityListner(IPropertyChangedListener listener) {
		if (listeners == null)
			listeners = new ArrayList<IPropertyChangedListener>();
		listeners.add(listener);
	}

	@Override
	public void removeEntityListner(IPropertyChangedListener listener) {
		if (listeners == null)
			return;
		else {
			if (listener != null)
				listeners.remove(listener);
			if (listeners.isEmpty())
				listeners = null;
		}
	}

	@Override
	public void firePropertyChanged() {
		if(listeners==null)return;
		for(int i=0;i<listeners.size();i++){
			listeners.get(i).properyChanged();
		}
	}

}
